from __future__ import annotations

from dataclasses import dataclass
from math import sin, radians


@dataclass
class SlingResult:
    branch_tension_kN: float
    shackles_required_kN: float
    note: str


def two_leg_sling(load_kN: float, included_angle_deg: float, d_factor: float = 1.0) -> SlingResult:
    """双肢吊索受力计算。

    公式：单肢拉力 T = W / (2·sin(θ/2)) × DAF
    - W: 吊装重量 kN
    - θ: 吊索夹角（顶角）
    - DAF: 动载系数（一般 1.05~1.3）
    """

    theta = radians(included_angle_deg)
    T = load_kN / max(1e-6, 2.0 * sin(0.5 * theta)) * d_factor
    return SlingResult(branch_tension_kN=T, shackles_required_kN=1.25 * T, note="卡环按1.25T取值")


